package com.enitiy;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class zhanjinhua {

	public static void main(String[] args) {
		//1.创造一副扑克牌
		//一共有52张扑克牌 其中分为方块、红心、黑桃、梅花
		List <String > poker = new ArrayList<String>();
		String pokerM = "" ;
		for(int i = 1 ;i<=13;i++){
			pokerM = String.valueOf(i);
			if(i==1){
				pokerM="A";
			}else if (i==11){
				pokerM="J";
			}else if (i==12){
				pokerM="Q";
			}else if (i==13){
				pokerM="K";
			}
			poker.add("♥"+pokerM);
			poker.add("♠"+pokerM);
			poker.add("方块"+pokerM);
			poker.add("♣"+pokerM);
		}
		System.out.println("洗牌前：");
		System.out.println(poker);
		//2.洗牌
		Random random = new Random();
		for(int i = 0 ;i<1000;i++){
			//随机两张牌位置
			int one = random.nextInt(52);
			int two = random.nextInt(52);
			//第一张牌信息
			String oneM = poker.get(one) ;
			//第二张牌的信息
			String twoM = poker.get(two);
			//两张牌交换
			poker.set(one, twoM);
			poker.set(two,oneM);
			
		}
		System.out.println("洗牌后：");
		System.out.println(poker);
		//3.发牌
		int pSize = 3;
		Map <String,List<String>> map = new HashMap<String,List<String>>();
		for (int i = 0; i < pSize; i++) {
			List <String> pkp = new ArrayList<String>();
			map.put("赌手"+i, pkp);
			
		}
		//开始发牌
		for (int i = 0; i < pSize*3; i++) {
			//获取发牌的位置
			List<String> list = map.get("赌手"+i%pSize);
			//从扑克牌中取出一张牌
			String pk = poker.get(i);
			list.add(pk);
			
		}
		//展示扑克牌
		Iterator<String> it = map.keySet().iterator();
		while(it.hasNext()){
			String name = it.next();
			List <String> PK = map.get(name);
			System.out.println(name);
			System.out.println(PK);
		}
	}

}
